import { Button, Input } from "antd"
import { addGoods, minGoods, changeGoods, asyncAdd } from "../../../../store/Cart"
import { useDispatch, useSelector } from "react-redux"
import { useState } from "react"
function Cart() {
  const dispatch = useDispatch()
  const goodsCount = useSelector((state) => state.cart_alisa.goodsCount)
  const [num,setNum] = useState('')
  const handleAdd =  (param) => {
    dispatch(asyncAdd(param))
  }
  return (
    <div>
      商品数量:可修改
      <Input value={goodsCount}></Input>
      <Button onClick={() => dispatch(addGoods())}>加</Button>
      <Button onClick={() => dispatch(minGoods())}>减</Button>

      <Input value={num} onChange={(event)=>setNum(event.target.value)}></Input>
      <Button onClick={() => dispatch(changeGoods(Number(num)))}>改数量</Button>
      <Button onClick={()=>handleAdd(Number(num))}>异步更改</Button>
    </div>
  )
}
export default Cart